package com.itheima;
/*
    String toLowerCase() : 将当前字符串字母全部转为小写
    String toUpperCase() : 将当前字符串字母全部转为大写

    String trim(): 消除当前字符串的首尾的空格

    boolean contains(String str): 判断当前字符串是否包含指定的内容,包含返回true,不包含就返回false

    boolean startsWith(String str): 判断当前字符串是否以指定内容开头
    boolean endWith(String str):  判断当前字符串是否以指定内容结尾

    int indexOf(String str) : 获取指定内容在当前字符串中第一次出现的索引位置
 */
public class Test12 {
    public static void main(String[] args) {
        //1. "士可杀,不可辱"翻译成英文
        String s1 = "   you can kill me, you can't fuck me    ";

        //2. 将s1转为全大写
        String s2 = s1.toUpperCase();
        System.out.println("s2 = " + s2);  //YOU CAN KILL ME, YOU CAN'T FUCK ME

        //3. 将s2转为全小写
        String s3 = s2.toLowerCase();
        System.out.println("s3 = " + s3);  //you can kill me, you can't fuck me

        //4. 将s1的首尾空格消除掉
        String s4 = s1.trim();
        System.out.println("s4 = " + s4);

        //5. 判断s1中是否包含"fuck"
        boolean flag1 = s1.contains("fuck1");
        System.out.println("flag1 = " + flag1);

        String s5 = "柳杨幂岩";
        //6. 判断s5这个人名是否姓"柳"
        boolean flag2 = s5.startsWith("柳");
        System.out.println("flag2 = " + flag2);

        //7. 判断s5这个人名是否叫"岩"
        boolean flag3 = s5.endsWith("岩");
        System.out.println("flag3 = " + flag3);

        String[] names = {"王二麻子","王巴丹","隔壁老王"};
        //作业: 统计咱们班姓"王"都有多少人

        String s6 = "上海的自来水来自海上";
        //8. 获取"海"字在s6中第一次出现的位置!
        int index = s6.indexOf("海");
        System.out.println("index = " + index);
    }

}
